package org.person.gift.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.person.gift.domain.PayOrder;
import org.person.gift.mapper.PayOrderMapper;
import org.person.gift.service.IPayOrderService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stark
 * @since 2024-02-24
 */
@Service
public class PayOrderServiceImpl extends ServiceImpl<PayOrderMapper, PayOrder> implements IPayOrderService {

    @Override
    public void cancelOrder(String businessId) {
        List<PayOrder> payOrders = selectList(
                new EntityWrapper<PayOrder>().eq("business_id", businessId));
        for (PayOrder payOrder : payOrders) {
            payOrder.setPayStatus(-1);
            payOrder.setUpdateTime(new Date());
        }
        updateBatchById(payOrders);
        //当订单取消，还要取消三方支付
    }
}
